Skip to content

aks/sync query cache changes#19

Open
aks wants to merge 22 commits intotsukasaoishi:mainfrom
aks:aks/sync-query-cache-changes
Open

aks/sync query cache changes#19
aks wants to merge 22 commits intotsukasaoishi:mainfrom
aks:aks/sync-query-cache-changes

Conversation

@aks
Copy link
Contributor

@aks aks commented Jun 6, 2017

This PR adds support for syncing query cache changes from the master connection cache to the replica query caches.

The new test script confirms that a cache syncing problems exists, with replica_query_cache_sync disabled, and then confirms that the problem does not occur when replica_query_cache_sync is enabled.

The feature is controlled by a class variable @@replica_query_cache_sync that is false by default -- in order to maintain backward compatibility and not provide any query cache behavior by default.

This PR was tested with the support for fake_replica enabled, which has been submitted as a separate PR.

Note: this PR supports both Rails 4.2+ and Rails 5

Also: I'm not happy with this PR as it currently stands. I wanted to show the problem, and a solution, but am not sure that this is the Right solution.

For example, I think query cache syncing should turn on automatically if query caching is enabled. What value would there be in not syncing when query caching is enabled?

Also, the tests pass most of the time, but once in a while, one of the tests fail, with the symptom of a recursive loop starting with the clear_query_cache method. Due to other urgencies, haven't had time to dig in a identify the root cause of this infrequent, spurious test failure.

Lastly, there needs to be a way to select the appropriate corresponding replica connection pool from any given master connection -- so that when the master connection invokes clear_query_cache (after an update or insert on that connection), it is easy (low-cost) to also trigger clear_query_cache on the replica connections in the replica connection pool.

@tsukasaoishi
Copy link
Owner

Thank you for showing the problem raising and solving method.
I also think that I need to think about this problem properly.
I m thinking about solutions to Rails 5.1 as well.
Please give me some time.

@tsukasaoishi tsukasaoishi force-pushed the master branch 3 times, most recently from 3bf0c11 to 50a20ae Compare February 11, 2019 15:54
@aks
Copy link
Contributor Author

aks commented Aug 30, 2019

Hi Tsukasa-san, ひさしぶりですね。

Have you considered how to maintain cache-coherency in the replica caches when master-writes occur?

@tsukasaoishi
Copy link
Owner

Hello Mr.Stebbens. Good to see you again.
QueryCache problem has already been solved.

Base automatically changed from master to main January 19, 2021 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants